﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Security.Cryptography;
using System.Text;

namespace wuliuback
{
    public partial class Trace : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string userId = Request["user_id"];
            string lat = Request["lat"];
            string lng = Request["lng"];
            string time = DateTime.Now.ToString();
            if (userId == null || userId.Length <= 0)
            {
                return;
            }
            string code = "";
            string msg = "";

            String sql = "";
            sql = "insert into t_course_trace (user_id,lat,lng,time) values('"+userId+"','"+lat+"','"+lng+"','"+time+"')";
            DbHelper dbHelper=new DbHelper();
            if (dbHelper.Insert(sql))
            {
                sql = "update t_user set last_login_time='"+new DateTime()+"', lat="+lat+", lng="+lng+" where user_id='"+userId+"'";
                dbHelper.Update(sql);
                code = "0";
                msg = "签到成功";
            }
            else
            {
                code = "-1";
                msg = "签到失败";
            }
            
            Response.Output.WriteLine("{\"code\":\""+code+"\",\"msg\":\""+msg+"\"}");
        }
    }
}
